﻿using System.Collections.Generic;

namespace IssueIT.Core.Domain.Model
{
	public class Comment
	{
		private readonly IList<Reply> _replies = new List<Reply>();

		public Comment(string text) : this(text, Company.Any)
		{
			Text = text;
		}

		public Comment(string text, Company visibleTo)
		{
			Text = text;
			VisibleTo = visibleTo;
		}

		// TODO -- ToHtml _> img tags to html image links
		public string Text { get; private set; }
		public Company VisibleTo { get; private set; }

		public IEnumerable<Reply> Replies
		{
			get
			{
				return _replies;
			}
		}

		public bool IsVisibleTo(User user)
		{
			return VisibleTo.Equals(Company.Any) || VisibleTo.Equals(user.Company);
		}

		public void AddReply(Reply reply)
		{
			_replies.Add(reply);
		}
	}
}